<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/conformanceFunction.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:reg="http://xbrl.org/2008/registry"
  xmlns:fcn="http://xbrl.org/2008/function"
  xmlns:cfcn="http://xbrl.org/2008/conformance/function"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:concept="http://xbrl.org/formula/conformance/example" 
  xmlns:s="http://xbrl.org/formula/conformance/example"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  http://xbrl.org/2008/conformance ../schemas/conformance.xsd
  http://xbrl.org/2008/conformance/function ../schemas/conformanceFunction.xsd
  ">
  <owners>
    <reg:owner id="herm">
      <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
      <reg:email>fischer@markv.com</reg:email>
     <reg:assumedOwnership moment="2008-02-19T00:00:00" />
    </reg:owner>
  </owners>

  <number>80201</number>

  <name>Function test xfi:s-equal</name>

  <documentation>
    <xhtml:p>
      Tests of function xfi:s-equal($left as node()*, $right as node()*) as xs:boolean
      </xhtml:p>
  </documentation>

  <reference xlink:type="simple" xlink:href="http://www.xbrl.org/Specification/XF-PWD-2006-12-07.htm#_Toc152670703"/>

  <variation id="V-01">
    <name>Returns s-equality of nodes equal and in order</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V01" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V01">
         xfi:s-equal( //xbrli:context[@id='c-V01-left'],
                      //xbrli:context[@id='c-V01-right'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:boolean and 
         count( $result ) eq 1 and
         $result eq true()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-02">
    <name>Same as V-01 but typed dimension elements in different order</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V02" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V02">
         xfi:s-equal( //xbrli:context[@id='c-V01-left'],
                      //xbrli:context[@id='c-V03-right'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:boolean and 
         count( $result ) eq 1 and
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-03">
    <name>Same as V-01 but arguments are sequences</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V03" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V03">
         xfi:s-equal( ( //xbrli:context[@id='c-V01-left'], //concept:P3[@id eq 'V02-left']),
                      ( //xbrli:context[@id='c-V01-right'], //concept:P3[@id eq 'V02-left']) )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:boolean and 
         count( $result ) eq 1 and
         $result eq true()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-04">
    <name>Same as V-01 but arguments are sequences not same length</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V04" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V04">
         xfi:s-equal( ( //xbrli:context[@id='c-V01-left'], //concept:P3[@id eq 'V02-left']),
                      ( //xbrli:context[@id='c-V03-right'] ) )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:boolean and 
         count( $result ) eq 1 and
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-05">
    <name>Example 25 contexts equal because entity and period are s-equal</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V05" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V05">
         xfi:s-equal( //xbrli:context[@id eq 'np3'],
                      //xbrli:context[@id eq 'Xnnp3X'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq true()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-06">
    <name>Example 25 f name and g name have different context ids np3 and Xnnp3X which are nevertheless s-equal</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V06" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V06">
         xfi:s-equal( //s:name[@id eq 'fName'],
                      //s:name[@id eq 'gName'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq true()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-07">
    <name>Example 25 b name and c name have different context ids np3 and Xnnp3X which are nevertheless s-equal</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V07" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V07">
         xfi:s-equal( //s:name[@id eq 'bName'],
                      //s:name[@id eq 'cName'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq true()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-08">
    <name>Example 25 b gross and c gross not s-equal</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V08" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V08">
         xfi:s-equal( //s:gross[@id eq 'bGross'],
                      //s:gross[@id eq 'cGross'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-09">
    <name>Example 25 b customer and c customer have different context ids np3 and Xnnp3X</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V09" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V09">
         xfi:s-equal( //s:customer[@id eq 'bCustomer'],
                      //s:customer[@id eq 'cCustomer'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-10">
    <name>Example 25 b returns and d returns have different values</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V10" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V10">
         xfi:s-equal( //s:returns[@id eq 'bReturns'],
                      //s:returns[@id eq 'dReturns'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-11">
    <name>Example 25 b customer and d customer have different values of returns and net</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="example25.xsd"/>
      <instance readMeFirst="true" id="V11" xlink:type="simple" xlink:href="example25-instance.xml"/>
      <cfcn:call file="V11">
         xfi:s-equal( //s:customer[@id eq 'bCustomer'],
                      //s:customer[@id eq 'dCustomer'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-12">
    <name>Wrong node to function</name>
    <documentation>
      <xhtml:p>
        XPath-defined error for node type incorrect.
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V12" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V12">
         xfi:s-equal( /xbrli:xbrl/xbrli:context[2], 'just a string' )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xqt-err:XPTY0004</error>
    </outputs>
  </variation>  

  <variation id="V-13">
    <name>A sequence of concepts as argument</name>
    <documentation>
      <xhtml:p>
        XPath-defined error for node type incorrect number of arguments.
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V13" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V13">
         xfi:s-equal( //xbrli:xbrl/xbrli:context[starts-with(@id,'c-V0')] )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xqt-err:XPST0017</error>
    </outputs>
  </variation>

  <variation id="V-14">
    <name>Would be expected to return s-equality of nodes equal and in order, but typed dimension contains an xbrli:dateUnion instant date.</name>
    <documentation>
      <xhtml:p>
        S-equality comparison of dateUnion with xs:date eq xs:dateTime will be performed using Base Spec 2.1 x-equality checking,
        which is done by comparing strings.  In this case the date of 2007-02-28 and dateTime of 2007-03-01T00:00:00 will be
        compared lexically (as strings, not as typed XPath 2 objects), so the result is false.
      </xhtml:p>
      <xhtml:p>
See Example 0004 (restatement date) for specific user-level XPath 2 coding to handle a typed dimension with a dateUnion known to report an instant date.
        XPath-defined error for type mismatch detection.
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V14" xlink:type="simple" xlink:href="s-equal2-dateUnion-instance.xml"/>
      <cfcn:call file="V14">
         xfi:s-equal( //xbrli:context[@id='c-V01-left'],
                      //xbrli:context[@id='c-V01-right'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result eq false()
      </cfcn:test>
      <!-- per IHR these comparisons are done as strings, so the result is false 
      <error>xqt-err:XPTY0004</error>
      -->
      <!-- test can't complete due to XPTY0004 issue of comparing
           xs:date to xs:dateTime in XPath 2
             <cfcn:test>
                $result instance of xs:boolean and 
                count( $result ) eq 1 and
                $result eq true()
             </cfcn:test>
      -->
    </outputs>
  </variation>

  <variation id="V-15">
    <name>Same as V-01 but nested IDs differ, to be sure this is detected as s-inequality (bug 378)</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="s-equal2.xsd"/>
      <linkbase xlink:type="simple" xlink:href="s-equal2-definition.xml"/>
      <instance readMeFirst="true" id="V15" xlink:type="simple" xlink:href="s-equal2-instance.xml"/>
      <cfcn:call file="V15">
         xfi:s-equal( //xbrli:context[@id='c-V04-left'],
                      //xbrli:context[@id='c-V04-right'] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:boolean and 
         count( $result ) eq 1 and
         $result eq false()
      </cfcn:test>
    </outputs>
  </variation>


  <revisions>
    <reg:revision on="2008-02-19T00:00:00" by="herm">
      <xhtml:p>
        Created the test case.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2010-01-31T10:30:00" by="herm">
      <xhtml:p>
        Updated V-01 - V-04 to remove nested ids, per bug 378, to ensure tests check the intent of test; variation v-15 added for nested id detection as s-inequality.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2010-09-11T00:00:00" by="herm">
      <xhtml:p>
        Corrected test case instances removing nested IDs in context typed dimension values per bug 378.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2010-10-16T00:00:00" by="herm">
      <xhtml:p>
        Per IHR, corrected V14 to have a false() result, when comparing date unions where one is a date
        and the other a dateTime, because they are compared lexically as strings, not as typed objects.
      </xhtml:p>
    </reg:revision>
  </revisions>

</testcase>
